package com.xin.jdbc;

import java.sql.*;

public class jdbcdemo_02 {
    public static void main(String[] args) {
        Connection conn=null;
        Statement sta=null;
        ResultSet re=null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/student_manage","root","856736");
            sta=conn.createStatement();
            re=sta.executeQuery("select * from stu_information");
            while (re.next()){
                System.out.println(re.getString(1)+re.getString(2)+
                        re.getString(3)+re.getString(4)+re.getString(5)+re.getString(6));
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (re!=null){
                try {
                    re.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }if (sta!=null){
                try {
                    sta.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }if (conn!=null){
                try {
                    conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }

        }
    }
}
